]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Fix temperature edge case
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 20 Dec 2020 22:11:26 +0000 (23:11 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 22 Dec 2020 09:27:45 +0000 (09:27 +0000)
We currently format the temperature with a precision of 0, that is
with no digits after the decimal-point. As a result, a temperature
like -0.2 shows up as -0.

Math.trunc() has the same effect as `%.0f` and handles that edge
case correctly, but while at it, we can just as well round the
value properly.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3441

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1548>

js/ui/dateMenu.js

index 993d49289697bc205ad3c0ced15c5ca992f201bc..33c054c12f8d58d56a13e6fe4f5cb67847c2672c 100644 (file)
@@ -567,7 +567,7 @@ class WeatherSection extends St.Button {
                 ampm: false,
             });
             const [, tempValue] = fc.get_value_temp(GWeather.TemperatureUnit.DEFAULT);
-            const tempPrefix = tempValue >= 0 ? ' ' : '';
+            const tempPrefix = Math.round(tempValue) >= 0 ? ' ' : '';
 
             let time = new St.Label({
                 style_class: 'weather-forecast-time',
@@ -582,7 +582,7 @@ class WeatherSection extends St.Button {
             });
             let temp = new St.Label({
                 style_class: 'weather-forecast-temp',
-                text: '%s%.0f°'.format(tempPrefix, tempValue),
+                text: '%s%d°'.format(tempPrefix, Math.round(tempValue)),
                 x_align: Clutter.ActorAlign.CENTER,
             });